# _*_ coding: UTF-8 _*_
# @Time     :2023-11-20 10:51
# @Author   :Yunlian Zeng
# @File     :04_notice.py
import requests

s = requests.Session()      #实例化一个会话对象

datas = {'emp_no':'admin','password':'admin'}   #post请求的正文
url = 'http://localhost/smeoa/login/check_login'
r = s.post(url, data=datas)    #默认重定向

if r.status_code == 200 and r.reason == 'OK' and '退出' in r.text:
    print('登陆成功')
else:
    print('登陆失败')

#获取公告页面
r = s.get('http://localhost/smeoa/notice/index')
# print(r.text)
if r.status_code == 200 and r.reason == 'OK' and '公告搜索' in r.text:
    print('获取公告页面成功')
else:
    print('获取公告页面失败')

#新增公告
# url = 'http://localhost/smeoa/notice_folder/save'
# # datas = {'id':'',
# #          'opmode':'add',
# #          'admin':'总经理1001/总经理|1001',
# #          'write':'总经理1001/总经理|1001',
# #          'read':'总经理1001/总经理|1001',
# #          'folder_list':'0',
# #          'name':'1120-1104',
# #          'folder_name':'学校',
# #          'pid':'69',
# #          'sort':'666',
# #          'is_del':'0',
# #          'remark':'123abc添加备注'}
# #以下正文内容，为必填项
# datas = {
#          'opmode':'add',
#          'name':'1120-1110',
#          'folder_name':'学校',
#          'pid':'69'
#          }
# r = s.post(url, data=datas)     #发送请求
# if r.status_code == 200 and r.reason == 'OK' and '新增成功' in r.text:
#     print('新增公告成功')
# else:
#     print('新增公告失败')


#删除公告
url = 'http://localhost/smeoa/notice_folder/index'
datas = {
         'id':'77',
             'opmode':'edit',
             'admin':'',
             'write':'',
             'read':'',
             'folder_list':'0',
             'name':'1120-1045',
             'folder_name':'学校',
             'pid':'69',
             'sort':'',
             'is_del':'0',
             'remark':'',
             'ajax':'1'}
r = s.post(url, data=datas)
try:
    print(r.json())
except:
    print(r.text)
